{% extends "layout/home_base.html" %}
{% block home_content %}
<div data-heading-extract-to="#menu-item-home_security">
<div class="row">
  <div class="medium-6 columns">
    <div class="section">
      <div class="section__header">
        <h1 class="section__title" id="email" data-heading>{{ _('Change Email') }}</h1>
      </div>
      <div class="section__body">
        <form method="post">
          {{ form.form_text(type='password', label='Current Password', columns=10, name='current_password', required=true) }}
          {{ form.form_text(type='text', label='Current Email', columns=10, name='current_email', value=handler.user['mail'], disabled=true) }}
          {{ form.form_text(type='text', label='New Email', columns=10, name='mail', required=true) }}
          <div class="row"><div class="columns">
            <input type="hidden" name="csrf_token" value="{{ handler.csrf_token }}">
            <input type="hidden" name="operation" value="change_mail">
            <input type="submit" class="rounded primary button" value="{{ _('Change Email') }}">
          </div></div>
        </form>
      </div>
    </div>
  </div>
  <div class="medium-6 columns">
    <div class="section">
      <div class="section__header">
        <h1 class="section__title" id="password" data-heading>{{ _('Change Password') }}</h1>
      </div>
      <div class="section__body">
        <form method="post">
          {{ form.form_text(type='password', label='Current Password', columns=10, name='current_password', required=true) }}
          {{ form.form_text(type='password', label='New Password', columns=10, name='new_password', required=true) }}
          {{ form.form_text(type='password', label='Repeat Password', columns=10, name='verify_password', required=true) }}
          <div class="row"><div class="columns">
            <input type="hidden" name="csrf_token" value="{{ handler.csrf_token }}">
            <input type="hidden" name="operation" value="change_password">
            <input type="submit" class="rounded primary button" value="{{ _('Change Password') }}">
          </div></div>
        </form>
      </div>
    </div>
  </div>
</div>
<div class="row">
  <div class="columns">
    <div class="section">
      <div class="section__header">
        <h1 class="section__title" id="session" data-heading>{{ _('Active Sessions') }}</h1>
      </div>
      <div class="section__body">
        <ul class="sessionlist">
          {% for session in sessions %}
          <li class="sessionlist__item">
            <div class="media">
              <div class="media__left medium">
                <span class="sessionlist__icon icon icon-platform--{{ session['update_ua']['icon'] }}"></span>
              </div>
              <div class="media__body medium typo">
                <p>{{ _('Last Update At') }}: {{ datetime_span(session['update_at']) }}</p>
                <p>{{ _('Location') }}: {{ _(session['update_geoip']) }} ({{ session['update_ip'] }})</p>
                <p>{{ _('Operating System') }}: {{ session['update_ua']['os'] }}</p>
                <p>{{ _('Browser') }}: {{ session['update_ua']['browser'] }}</p>
                <!-- {{ _('User-Agent') }}: {{ session['update_ua']['str'] }} -->
                <p>{{ _('Type') }}: {{ _(vj4.handler.home.TOKEN_TYPE_TEXTS[session['token_type']]) }}</p>
                {% if session['is_current'] %}
                <p class="sessionlist__current-session"><span class="icon icon-check"></span> {{ _('This is the current session') }}</p>
                {% endif %}
              </div>
              {% if not session['is_current'] %}
              <div class="media__right medium">
                <form method="post">
                  <input type="hidden" name="operation" value="delete_token">
                  <input type="hidden" name="token_type" value="{{ session['token_type'] }}">
                  <input type="hidden" name="token_digest" value="{{ session['token_digest'] }}">
                  <input type="hidden" name="csrf_token" value="{{ handler.csrf_token }}">
                  <input type="submit" value="{{ _('Logout This Session') }}" class="rounded button">
                </form>
              </div>
              {% endif %}
            </div>
          </li>
          {% endfor %}
        </ul>
      </div>
      <div class="section__body">
        <form method="post">
          <input type="hidden" name="operation" value="delete_all_tokens">
          <input type="hidden" name="csrf_token" value="{{ handler.csrf_token }}">
          <input type="submit" value="{{ _('Logout All Sessions') }}" class="primary rounded button">
        </form>
        <div class="typo">
          <p><small>IP geo-location data is provided by <a href="http://www.maxmind.com" target="_blank">MaxMind</a>.</small></p>
        </div>
      </div>
    </div>
    </div>
  </div>
</div>
{% endblock %}
